<template>
  <div class="header" @click="showDetail">
    <div class="content-wrapper">
      <div class="avatar">
        <img width="64" height="64" :src="seller.avatar" />
      </div>
      <div class="content">
        <div class="title">
          <span class="brand"></span>
          <span class="name">{{seller.name}}</span>
        </div>
        <div class="description">{{seller.description}}/{{seller.deliveryTime}}分钟送达</div>
        <div v-if="seller.supports" class="support">
          <span class="icon"></span>
          <span class="text">{{seller.supports[0].description}}</span>
        </div>
      </div>
      <div v-if="seller.supports" class="support-count">
        <span class="count">{{seller.supports.length}}个</span>
        <i class="icon-keyboard_arrow_right"></i>
      </div>
    </div>
    <div class="bulletin-wrapper">
      <span class="bulletin-title"></span>
      <span class="bulletin-text">{{seller.bulletin}}</span>
      <i class="icon-keyboard_arrow_right"></i>
    </div>
    <div class="background">
      <img :src="seller.avatar" width="100%" height="100%" />
    </div>
  </div>
</template>
<script>
  import SupportIco from 'components/support-ico/support-ico'

  export default {
    name: 'v-header',
    props: {
      seller: {
        type: Object,
        default() {
          return {}
        }
      }
    },
    methods: {
      showDetail() {
        // Comp是component的缩写
        // 因为每一次可能不是都要调用这个方法，所以先可以等于它本身;或者是使用createAPI创建的一个新的组件
        this.headerDetailComp = this.headerDetailComp || this.$createHeaderDetail({
          // porps 用于传递给组件的 Props ；$events用于 组件的 Events 事件回调
          $props: {
            // seller是响应式的
            // 第一步：创建出来
            seller: 'seller'
          }
        })
        // 第二步：show出来，方法在header-detail中定义
        this.headerDetailComp.show()
      }
    },
    components: {
      SupportIco
    }
  }
</script>

<style lang="stylus" scoped>
@import '~common/stylus/mixin'
@import '~common/stylus/variable'
.header
  position relative
  overflow hidden
  color $color-white
  background $color-background-ss
  .content-wrapper
    position relative
    padding 24px 12px 18px 24px
    font-size 0
    .avatar
      vertical-align top
      display inline-block
      img
        border-radius 2px
    .content
      display inline-block
      margin-left 16px
      font-size $fontsize-medium
      .title
        margin 2px 0 8px 0
        .brand
          vertical-align top
          display inline-block
          width 30px
          height 18px
          // 组件依赖的图片是放在组件的同级目录下
          bg-image('brand')
          background-size 30px 18px
          background-repeat no-repeat
        .name
          font-size $fontsize-large
          font-weight bold
          line-height 18px
          margin-left 6px
      .description
        font-size $fontsize-small
        margin-bottom 10px
      .support
        .icon
          margin-right 4px
        .text
          font-size $fontsize-small-s
          line-height 12px
    .support-count
      position absolute
      right 12px
      bottom 18px
      height 24px
      padding 0 8px
      background rgba(0, 0, 0, 0.2)
      text-align center
      border-radius 14px
      .count
        font-size $fontsize-small-s
        border none
      .icon-keyboard_arrow_right
        margin-left 2px
        line-height 24px
        font-size $fontsize-small-s
  .bulletin-wrapper
    background $color-background-sss
    position relative
    height 28px
    line-height 28px
    padding 0 22px 0 12px
    white-space nowrap
    overflow hidden
    text-overflow ellipsis
    .bulletin-title
      vertical-align top
      margin-top 8px
      display inline-block
      margin-right 4px
      width 22px
      height 12px
      bg-image 'bulletin'
      background-size 22px 12px
      background-repeat no-repeat
    .bulletin-text
      font-size $fontsize-small-s
      line-height 28px
    .icon-keyboard_arrow_right
      position absolute
      right 12px
      top 8px
      font-size $fontsize-small-s
      margin-left 4px
  .background
    position absolute
    left 0
    top 0
    width 100%
    height 100%
    z-index -1
    filter blur(10px)
</style>
